package com.erdos.common.util;

import java.text.MessageFormat;
/**
 * This class is used to format message, and return the formatted message.Using as below:
 * <pre>
 *
 *   //use MsgFormat
 *   String msg1 = MsgFormat.format(ACTION START, "create new department", "ian");
 *   String msg2 = MsgFormat.format("SQL", "store department data to db", "insert into department values ('1', 'MIS') ");
 *
 *   Message samples as:
 *     public static String ACTION_START  = "ACTION METHOD START <{0}>, User is <{1}>.";	
 *     public static String SQL = "{0}, SQL <{1}>.";
 *     ...
 *   
 * </pre>
 */
public class MsgFormat {

    private MsgFormat() {
    }

    /**
     * Format the message according to the message name and arguments.
     * @param msgName Message name
     * @param args    Message arguments array
     * @return Formatted message
     */
    public static String format(String msgName, Object[] args) {
        return MessageFormat.format(msgName, args);
    }

	/**
	 * Format the message according to the message name and arguments.
	 * @param msgName Message name
	 * @param arg0    Message argument 0
	 * @return Formatted message
	 */
    public static String format(String msgName, Object arg0) {
        Object[] o = { arg0 };
        return format(msgName, o);
    }

	/**
	 * Format the message according to the message name and arguments.
	 * @param msgName Message name
	 * @param arg0    Message argument 0
	 * @param arg1    Message argument 1
	 * @return Formatted message
	 */
	public static String format(String msgName, Object arg0, Object arg1) {
		Object[] o = { arg0, arg1 };
		return format(msgName, o);
	}

	/**
	 * Format the message according to the message name and arguments.
	 * @param msgName Message name
	 * @param arg0    Message argument 0
	 * @param arg1    Message argument 1
	 * @param arg2    Message argument 2
	 * @return Formatted message
	 */
	public static String format(String msgName, Object arg0, Object arg1, Object arg2) {
		Object[] o = { arg0, arg1, arg2 };
		return format(msgName, o);
	}

	/**
	 * Format the message according to the message name and arguments.
	 * @param msgName Message name
	 * @param arg0    Message argument 0
	 * @param arg1    Message argument 1
	 * @param arg2    Message argument 2
	 * @param arg3    Message argument 3   
	 * @return Formatted message
	 */
	public static String format(String msgName, Object arg0, Object arg1, Object arg2, Object arg3) {
		Object[] o = { arg0, arg1, arg2, arg3 };
		return format(msgName, o);
	}
	

/*
    public static void main(String args[]) throws Exception {
        //     SysMsg sm = SysMsg.getSysMsg();
        //     sm.setBaseName("util.systemmsg");
        ArrayList al = new ArrayList();
        al.add("T1");
        al.add("T2");
        al.add("T3");
        al.add("T4");
        String[] ary = new String[] { "B1", "B2" };
        al.add(ary);
        System.out.println("ary: " + ary.toString());

        HashMap hm = new HashMap();
        hm.put("0", "aaa");
        hm.put("1", "bbb");
        System.out.println("hm :" + hm.toString());
        al.add(al);

        System.out.println("ArrayList: " + al.toString());

        System.out.println("test");


        System.out.println("sleep start");
        Thread.sleep(30000);
        System.out.println("sleep end");

        System.out.println(MsgFormat.format("NO_CON", "abc"));
        //System.out.println(SysMsg.getSysMsg().format("NO_RMS_INFO","aaa"));

    }
*/
}